package com.ledong;

public class Sort {
    public static void main(String[] args) {
        bubbleSort(new int[] { 0, 3, 2, 5, 4, 9, 1, 8, 6, 7 });
    }

    /**
     * 冒泡排序
     * 
     * @param array
     */
    public static void bubbleSort(int[] array) {
        for (int i = 0; i < array.length - 1; ++i) {
            for (int j = 0; j < array.length - i - 1; ++j) {
                if (array[j] > array[j + 1]) {
                    int temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                }
            }
        }
        for (int i : array) {
            System.out.print(i + " ");
        }
    }

}
